package org.jeecg.api.utils;

import org.jeecg.common.system.util.SignDO;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.recruit.appuser.entity.MmAppUser;
import org.springframework.stereotype.Component;

/**
 * @author zhongchao
 * @tile MiniappSpringContextUtils
 * @date 2020/8/24
 * @since v1.0.0
 */
@Component
public class MiniappSpringContextUtils extends SpringContextUtils {


    /**
     * 签名解码信息
     */
    public static final String MINIAPP_SIGNDO = "signDO";


    /**
     * session中存储用户信息
     */
    public static final String MINIAPP_USER = "miniapp_user";


    /**
     * 获取HttpServletRequest
     */
    public static SignDO getSignDO() {
        return (SignDO) getHttpServletRequest().getSession().getAttribute(MINIAPP_SIGNDO);
    }

    /**
     * 获取HttpServletRequest
     */
    public static void setSignDO(SignDO signDO) {
        getHttpServletRequest().getSession().setAttribute(MINIAPP_SIGNDO, signDO);
    }

    /**
     * 获取HttpServletRequest
     */
    public static MmAppUser getMmAppUser() {
        return (MmAppUser) getHttpServletRequest().getSession().getAttribute(MINIAPP_USER);
    }

    /**
     * 获取HttpServletRequest
     */
    public static void setMmAppUser(MmAppUser mmAppUser) {
        getHttpServletRequest().getSession().setAttribute(MINIAPP_USER, mmAppUser);
    }

}
